package mid

/*
  - @author: hjz
  - @time: 2025/6/4 22:05
  - @desc: 3. 无重复字符的最长子串
    8ms击败39.28%
*/
func lengthOfLongestSubstring(s string) int {
	l, r := 0, 0
	var res int
	m := make(map[byte]int)
	for r < len(s) {
		if i, ok := m[s[r]]; ok && i >= l {
			l = i + 1
		}
		m[s[r]] = r
		res = maxT(res, r-l+1)
		r++
	}
	return res
}
